<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@include file="/WEB-INF/views/include/inc.jsp"%>
<!DOCTYPE html >
<html>
<head>
<%@include file="/WEB-INF/views/include/head.jsp"%>
<link href="<%=contextPath %>/assets/hplus/css/plugins/iCheck/custom.css" rel="stylesheet">
</head>
<body style="background-color: white;" class="gray-bg">
<div class="wrapper wrapper-content animated">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form  class="form-horizontal m-t" id="signupForm">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">资源名：</label>
                                <div class="col-sm-8">
                                    <input id="name" name="name" value="" class="form-control" type="text">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">描述：</label>
                                <div class="col-sm-8">
                                    <input id="description" name="description" value="" class="form-control" type="text" aria-required="true" aria-invalid="false" class="valid">
                                </div>
                            </div>
                             <div class="form-group">
                                <label class="col-sm-3 control-label">菜单地址：</label>
                                <div class="col-sm-8">
                                    <input id="href" name="href" value="" class="form-control" type="text" aria-required="true" aria-invalid="false" class="valid">
                                </div>
                            </div>
                            
                            <div class="form-group">
                            <label class="col-sm-3 control-label">类型：</label>
                            <div class="col-sm-8">
                                <select name="type"  class="form-control m-b" style="width:350px;" tabindex="2">
                                    <option value="0">目录</option>
                                   	<option value="1">菜单</option>
                                   	<option value="2">业务</option>
                                </select>
                            </div>
                        </div>
                         <div class="form-group">
                                <label class="col-sm-3 control-label">图标：</label>
                                <div class="col-sm-8">
                                    <input id="icon" name="icon" value="" class="form-control" type="text" aria-required="true" aria-invalid="false" class="valid">
                                </div>
                            </div>
                        	<div class="form-group">
                                <label class="col-sm-3 control-label">权限：</label>
                                <div class="col-sm-8">
                                    <input id="permission" name="permission" value="" class="form-control" type="text" aria-required="true" aria-invalid="false" class="valid">
                                </div>
                            </div>
                             <div class="form-group">
                            <label class="col-sm-3 control-label">上级：</label>
                            <div class="col-sm-8">
                                <select name="parent.id" data-placeholder="选择类型" class="form-control m-b" style="width:350px;" tabindex="2">
                                    <option value="0">--顶级目录--</option>
                                    <c:forEach items="${ parents}" var="type1">
                                    	<option value="${type1.id}" hassubinfo="true">&nbsp;&nbsp;&nbsp;${type1.name}</option>
                                    	<c:forEach items="${ type1.children}" var="type2">
                                    		<option value="${type2.id}" hassubinfo="true">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${type2.name}</option>
                                    	</c:forEach>
                                	</c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                                <label class="col-sm-3 control-label">排序：</label>
                                <div class="col-sm-8">
                                    <input id="sort" name="sort" value="" class="form-control" type="text" aria-required="true" aria-invalid="false" class="valid">
                                </div>
                            </div>
                        <div class="form-group">
                                <label class="col-sm-3 control-label">是否显示：</label>
                                <div class="col-sm-8">
                                     <div class="checkbox i-checks">
                                        <label>
                                            <input name="display" type="checkbox" value="1" spellcheck="0" checked="checked"> <i></i> 显示</label>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <button class="btn btn-primary" type="submit">提交</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>
	<%@include file="/WEB-INF/views/include/foot.jsp"%>
	
	<!-- 自定义js -->
	<script
		src="<%=contextPath%>/assets/hplus/js/content.min.js?v=1.0.0"></script>

	<!-- jQuery Validation plugin javascript-->
	<script
		src="<%=contextPath%>/js/jquery.form.js"></script>
	<script
		src="<%=contextPath%>/assets/hplus/js/plugins/validate/jquery.validate.min.js"></script>
	<script
		src="<%=contextPath%>/assets/hplus/js/plugins/validate/messages_zh.min.js"></script>
	 <script src="<%=contextPath%>/assets/hplus/js/plugins/iCheck/icheck.min.js"></script>
    <script>
        $(document).ready(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
        });
    </script>
	<script>
		$.validator.setDefaults({
			highlight : function(a) {
				$(a).closest(".form-group").removeClass("has-success")
						.addClass("has-error")
			},
			success : function(a) {
				a.closest(".form-group").removeClass("has-error").addClass(
						"has-success")
			},
			errorElement : "span",
			errorPlacement : function(a, b) {
				if (b.is(":radio") || b.is(":checkbox")) {
					a.appendTo(b.parent().parent().parent())
				} else {
					a.appendTo(b.parent())
				}
			},
			errorClass : "help-block m-b-none",
			validClass : "help-block m-b-none"
		});
		var index = parent.layer.getFrameIndex(window.name);
		$().ready(function() {
			$("#commentForm").validate();
			var a = "<i class='fa fa-times-circle'></i> ";
			$("#signupForm").validate({
				rules : {
					name : "required"
				},
				messages : {
					name : a + "请输入你的姓"
				},
				 submitHandler:function(form){
					 $(form).ajaxSubmit({
						 	
			            	url:'<%=contextPath%>/sys/resource/add',
			            	type:'post',
			            	dataType:"json",
			            	success:function(data){
			            		if(data.code==200){
			            			parent.$('#search').text("reloadGrid");
				            		parent.layer.close(index); //执行关闭
			            		}else{
			            			
			            		}
			            	}
		              }); 
		        }
			});
			$("#username").focus(function() {
				var c = $("#firstname").val();
				var b = $("#lastname").val();
				if (c && b && !this.value) {
					this.value = c + "." + b
				}
			})
		});
	</script>
</body>
</html>